//
//  WeeklyLetterBean.swift
//  imprint
//
//  Created by 小柠檬🍋 on 2025/2/22.
//

import Foundation
import GRDB

//每周来信
public class WeeklyLetterBean : ICloudTable,IDbTable, Identifiable {
    
    public static let databaseTableName = "WeeklyLetter"

    func getCloudTable() -> String {
        return "WeeklyLetter"
    }
    
    //leanCloud 排除字段
    func doCustomExcluded() -> [String? : Any?] {
        return doExcluded(subject: self, excluded: ["createTime","updateTime","modifySign","status"])
    }
    
    //db排除字段
    func doCustomDBExcluded()  -> [String? : Any?] {
        return doExcluded(subject: self, excluded: [""])
    }
    
    var objectId: String?
    var weekOfYear: String? = nil//信件的唯一识别码 写法为 2024_1 2024年第1周
    var time: Int64 = 0//信件时间，
    var acceptTime: Int64 = 0//接受时间
    var name: String? = nil//写信名称
    var avatar: String? = nil//头像
    var roleId: String? = nil//写信id
    var content: String? = nil//信件内容
    var voicePath: String? = nil//语音路径
    var userId: String? = nil
    var read: Bool = false
    var title: String? = nil

    var createTime: Int64 = 0//创建时间
    var updateTime: Int64 = 0//更新时间时间
    var modifySign: Bool = false//修改标识
    var status: Int = IStatusType.NORMAL.rawValue
    
    //json解析白名单
    private enum CodingKeys: String, CodingKey {
        case objectId
        case weekOfYear
        case time
        case acceptTime
        case name
        case avatar
        case roleId
        case content
        case voicePath
        case userId
        case read
        case title

//        case createTime
//        case updateTime
//        case modifySign
//        case status
        }
}

extension WeeklyLetterBean {
    // db数据库指定字段
    public func encode(to container: inout PersistenceContainer) {
        doDBExcluded(to: &container)
    }
}
